package com.robinloveshadow.goodnight;

import com.robinloveshadow.goodnight.sounds.SoundsManager;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.provider.Settings;
import android.util.Log;

public class WifiControlReceiver extends BroadcastReceiver{
	private static final String TAG = "TimeChangedReceiver";
	private static final boolean D = false|Constance.D_ALL;

	@Override
	public void onReceive(Context context, Intent intent) {
		if(D) Log.d(TAG, "onReceive");
		if(D) Log.d(TAG, "onReceive : BINGGO! wake up!");
		SoundsManager.getInstance(context).setRingerMode(AudioManager.RINGER_MODE_NORMAL);
		setAirplaneModeOn(context, false);
		
	}

	public void setAirplaneModeOn(Context context,boolean enabling) {
		// Change the system setting

		Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,enabling ? 1 : 0);

		// Post the intent

		Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
		intent.putExtra("state", enabling);
		context.sendBroadcast(intent);
	}
}
